﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Chuong02
{
    public class TargetCamera:Camera
    {
        private Vector3 position;

        public Vector3 Position
        {
            get { return position; }
            set { position = value; }
        }

        private Vector3 target;

        public Vector3 Target
        {
            get { return target; }
            set { target = value; }
        }

        public TargetCamera(Vector3 position, Vector3 target, GraphicsDevice graphicsDevice):base(graphicsDevice)
        {
            this.Position = position;
            this.Target = target;
        }

        public override void Update()
        {
            Vector3 forward = Target - Position;
            Vector3 side = Vector3.Cross(forward, Vector3.Up);

            Vector3 up = Vector3.Cross(forward,side);

            //this.Projection = Matrix.CreatePerspectiveFieldOfView(
            //MathHelper.ToRadians(45), GraphicsDevice.Viewport.AspectRatio,
            //0.1f, 10000.0f);
      
            this.View = Matrix.CreateLookAt(Position,Target, up);

        }
   }


}
